package com.younio.local.util;

import java.io.IOException;
import java.io.InputStream;

public class ScriptUtils {

    public static void run(String cmd) {
        try {
            Process process = Runtime.getRuntime().exec(cmd);
            InputStream in = process.getInputStream();
            int tmp;
            StringBuilder sb = new StringBuilder();
            while ((tmp = in.read()) != -1) {
                sb.append((char) tmp);
            }
            in.close();
            System.out.println(new String(sb.toString().getBytes(), "UTF-8"));
            process.waitFor();
            System.out.println("------------------------------------------");
        } catch (IOException | InterruptedException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        run("calc");
    }
}
